package com.dyz.leetcode._01_array;

public class _238_productExceptSelf {
    public int[] productExceptSelf(int[] nums) {
        int n = nums.length;
        int[] prex = new int[n];
        int cur = 1;
        for (int i=0; i<n; i++){
            prex[i] = cur;
            cur = nums[i]*cur;
        }
        cur = 1;
        for (int i = n-1; i>=0; i--){
            prex[i] = prex[i]*cur;
            cur = nums[i]*cur;
        }
        return prex;
    }
}
